-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aws-codebuild): add enableBatchBuilds()
to Project
#12531
Conversation
20f197e
to
8eade4c
Compare
supportBatchBuildType
option to Project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the contribution @tjenkinson !
May I suggest something? 🙂.
Your change currently says, "if you use webhookTriggersBatchBuild
, you have to use supportBatchBuildType
too". I would posit that that's actually backwards, and what you want is actually: "if you use webhookTriggersBatchBuild
, CDK will make sure that that supportBatchBuildType
is set!" 🙂.
Given that, I'd suggest the following changes:
- Make the
buildBatchConfig
in theCfnProject
be set with a Lazy (likeencryptionKey
is, for example). - Remove the
supportBatchBuildType
property fromProjectProps
. - Add a method
enableBatchBuilds(): BatchBuildConfig | undefined
toIProject
. It will returnundefined
for imported Projects, where this cannot be changed. For new Projects, it will create a new Role like you do today, and set thebuildBatchConfig
private property of the L1 so that the above Lazy can set it.BatchBuildConfig
is a very simple new interface that only contains arole
property. You should return the newly created Role there, so that customers can update it if necessary. The new method also gives us flexibility in adding an optionalrole
argument to it in the future. - In the
ThirdPartyGitSource
, ifwebhookTriggersBatchBuild
was set totrue
, call theenableBatchBuilds()
method on theIProject
instance it gets inbind()
. - Similarly in
CodeBuildAction
: ifexecuteBatchBuild
was set totrue
, call theenableBatchBuilds()
method on theIProject
it gets in the properties.
Let me know if this description is clear, or if you need any help implementing it!
Makes sense to me. Will update. |
Pull request has been modified.
a854534
to
2aa8ccf
Compare
@skinny85 updated. I left the Also I made the Thoughts? Finally I updated the action integration test and added a new integration test for a batch webhook trigger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @tjenkinson ! Some minor comments below. I see where you're coming from, but I have reasons to stay with the design I've initially proposed - I've explained them in the review comments. Hope you agree!
because it is not set when sources are bound
Pull request has been modified.
/** | ||
* The return value for the {@link Project} `enableBatchBuilds()` method. | ||
*/ | ||
export interface IEnableBatchBuildsReturn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skinny85 I named this this instead of BatchBuildConfig
because I didn't want it to get confused with the actual buildBatchConfig
in L1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh. The type on the L1 level is called ProjectBuildBatchConfigProperty
, so I'm not too worried about this one being called BatchBuildConfig
.
The name is not a coincidence - it's actually a convention we use for return types (see examples [1], [2]).
A name ending in Return
seems a little weird given that, so if you could change it, I would appreciate it 🙂.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem will update then. Thanks for the examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @tjenkinson ! One more rename to go, and some clarifying questions. But this will be shipped very soon!
/** | ||
* The return value for the {@link Project} `enableBatchBuilds()` method. | ||
*/ | ||
export interface IEnableBatchBuildsReturn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh. The type on the L1 level is called ProjectBuildBatchConfigProperty
, so I'm not too worried about this one being called BatchBuildConfig
.
The name is not a coincidence - it's actually a convention we use for return types (see examples [1], [2]).
A name ending in Return
seems a little weird given that, so if you could change it, I would appreciate it 🙂.
produce: () => this.projectArn, | ||
})], | ||
actions: ['codebuild:StartBuild', 'codebuild:StopBuild', 'codebuild:RetryBuild'], | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need some batch permissions here? Like this? https://github.com/aws/aws-cdk/pull/12181/files?file-filters%5B%5D=.ts#diff-7902b8e1bfd8571028c1c97116a58c4f6e090f92d7df3490e16e12defbfa2fab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. The docs don't mention it and it worked when I tested this in a different account.
Think this is so that internally non batch builds can be triggered as part of a batch. Don't think a batch can trigger another batch?
Co-authored-by: Adam Ruka <adamruka85@gmail.com>
Pull request has been modified.
supportBatchBuildType
option to ProjectenableBatchBuilds()
to Project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for the contribution and working on the PR iterations @tjenkinson!
No problem thanks for the help! Hopefully this is the last PR we need to get batch builds working 🤞 |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
In order for a CodeBuild to run in batch mode, a batch service role is needed, as described here in the docs.
At first I thought lets add this by default, but then I realised when
BatchConfiguration
is set to something, in the aws console the default 'start build' button behaviour changes to start a batch build by default instead :/So now this adds a new
supportBatchBuildType
option, which whentrue
adds minimum amount ofBatchConfiguration
needed for batch builds to run.I also updated the doc blocks for the webhook option and CodePipeline action option, because users of those also need to set this option. It would be nice to auto-enable this if a webhook or CodeBuild action is configured, but that sounds pretty complicated.
I'm not sure why anyone would need to customise this role, given it appears to only be used internally to do those 3 things, so this PR does not make it configurable. My thinking is that this could be added later if needed, but this PR just gets batch builds working.
In the future if people want control of the other
BatchConfiguration
options I was thinking these could be added and would requiresupportBatchBuildType
to betrue
.related: aws-cloudformation/cloudformation-coverage-roadmap#621